package com.mdd.common.mapper.user;

import com.mdd.common.core.basics.IBaseMapper;
import com.mdd.common.entity.user.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;

/**
 * 用户Mapper
 */
@Mapper
public interface UserMapper extends IBaseMapper<User> {

    @Select({"SELECT SUM(user_money) FROM ls_user WHERE delete_time IS NULL "})
    BigDecimal getTotalUserAmount();


    @Select({"SELECT SUM(total_order_amount) FROM ls_user WHERE delete_time IS NULL "})
    BigDecimal getTotalUserConsumedAmount();

    @Select({"SELECT COUNT(id) FROM ls_user WHERE delete_time IS NULL "})
    Long getUserCount();


    @Select("SELECT count(id) FROM ls_user WHERE create_time >= #{start} AND create_time <= #{end} AND delete_time IS NULL")
    Long getTodayNewUserCount(@Param("start") Long start, @Param("end") Long end);

}
